package com.test.example.controller.repeat;

import com.xingluo.tools.repeat.anno.RepeatSubmit;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "日志工具测试")
@RestController
public class RepeatController {

    @Operation(summary = "无参防重复提交请求")
    @GetMapping("/repeat")
//    @RepeatSubmit(1000)
    @RepeatSubmit(value = 6000, message = "重复")
    public String repeat() {
        return "防重复提交";
    }

    /**
     * form-data格式
     */
    @PostMapping("/repeat2")
    @RepeatSubmit(value = 6000, message = "重复")
    public String repeat2(String username, String password) {
        return username + "：" + password;
    }

    /**
     * form-data格式
     */
    @PostMapping("/repeat3")
    @RepeatSubmit(value = 6000, message = "重复")
    public String repeat3(User user) {
        return user.getUsername() + "：" + user.getPassword();
    }

    /**
     * json数据格式
     */
    @PostMapping("/repeat4")
    @RepeatSubmit(value = 6000, message = "重复")
    public String repeat4(@RequestBody User user) {
        return user.getUsername() + "：" + user.getPassword();
    }
}
